package com.wgworkshop.games.raindrop;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Raindrop extends Game {
    final int WIDTH = 800;
    final int HEIGHT = 480;

    SpriteBatch batch;
    BitmapFont font;

    int highScore;

    private FileHandle saveFile;

    @Override
    public void create() {
        batch = new SpriteBatch();
        font = new BitmapFont();

        saveFile = Gdx.files.local("save.txt");
        if (saveFile.exists() && !saveFile.isDirectory()) {
            String content = saveFile.readString();
            highScore = Integer.parseInt(content);
        }

        setScreen(new MainMenuScreen(this));
    }

    @Override
    public void render() {
        super.render();
    }

    @Override
    public void dispose() {
        batch.dispose();
        font.dispose();

        screen.dispose();

        saveFile.writeString(String.valueOf(highScore), false);
    }
}
